package com.company.project.controller.ldjsc.swwj;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.company.project.entity.ldjsc.swwj.JscSwwjQswwzyzkEntity;
import com.company.project.entity.ldjsc.swwj.JscwzSwwjDigitalProtectionEntity;
import com.company.project.service.ldjsc.swwj.JscwzSwwjDigitalProtectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.company.project.common.utils.DataResult;




/**
 *
 *
 * @author wenbin
 * @email *****@mail.com
 * @date 2025-08-20 16:11:40
 */
@Controller
@RequestMapping("/sxzy")
public class JscwzSwwjDigitalProtectionController {
    @Autowired
    private JscwzSwwjDigitalProtectionService jscwzSwwjDigitalProtectionService;


    @ApiOperation(value = "文物数字化保护")
    @GetMapping("/jsc-dd-zt/JscProtection2")
    @ResponseBody
    public DataResult findListByPage(JscwzSwwjDigitalProtectionEntity jscwzSwwjDigitalProtection){
        LambdaQueryWrapper<JscwzSwwjDigitalProtectionEntity> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(JscwzSwwjDigitalProtectionEntity::getTitle, jscwzSwwjDigitalProtection.getTitle());
        queryWrapper.orderByDesc(JscwzSwwjDigitalProtectionEntity::getUpdate_time);

        if (jscwzSwwjDigitalProtection.getMidgard_offset() != null){
            jscwzSwwjDigitalProtection.setMidgard_page(1);
        }
        IPage<JscwzSwwjDigitalProtectionEntity> iPage = jscwzSwwjDigitalProtectionService.page(jscwzSwwjDigitalProtection.getQueryPage(), queryWrapper);
        List<JscwzSwwjDigitalProtectionEntity> records = iPage.getRecords();


        // 构造所需的数据结构
        List<String> columnNames = Arrays.asList(
                "id",
                "model",
                "type",
                "title",
                "sub_title",
                "detail",
                "sort",
                "source",
                "date",
                "index_name",
                "time_type",
                "update_time"
        );

        Map<String, Object> result = new HashMap<>();
        result.put("columnNames", columnNames);
        result.put("value", records);

        return DataResult.success(result);
    }




}
